﻿﻿$(function(){
 //监听登录页面消息
    if(window.ActiveXObject){ //判断是否为IE
        window.attachEvent("onmessage", function (e) {
            var data = JSON.parse(e.data);
            if(data.action == "qq" || data.action == "wx"){
                $("#frameItem").removeClass("frameItem").addClass("login_three_iframe");
                $(".pop_box").removeClass("login_box").addClass("login_three");
            }
        });
    }else{
        window.addEventListener('message',function(e){
            var data = JSON.parse(e.data);
            if(data.action == "qq" || data.action == "wx"){
                $("#frameItem").removeClass("frameItem").addClass("login_three_iframe");
                $(".pop_box").removeClass("login_box").addClass("login_three");
            }
        },false);
    }
 });﻿

var showLogin = function(option) 
{
    if (option == 1){
     window.location.href = "/login?option=1";
    }else{
     window.location.href = "/login";
    }

}

function logout() {
     $.post('/logout/',{},function(){

    })
    var callback = 'http://' + location.host + location.pathname + location.search;
    window.location.href =  callback;
}

$(".logout").click(function(e){
    e.preventDefault();
	logout();
})

$(".login").click(function(e){
    e.preventDefault();
	showLogin(0);
})
$(".reg").click(function(e){
    e.preventDefault();
    showLogin(1)

})
$(".pop_close").click(function(){
    $(".pop").hide();
})

$("#frameItem").load(function() {
       // var iDoc = ifr.contentDocument || ifr.document
       // console.log(iDoc);
       // $(this).contents().find("zs").css("background","red");
      // console.log($(document.getElementById('frameItem').contentWindow.document.body).find("#zx").html());
      $(document.getElementById('frameItem').contentWindow.document.body).find("#btnLogin,#nextBtn").css("background","red");
      $(document.getElementById('frameItem').contentWindow.document.body).find(".targetBtn").css("color","#42abdf");
})
